package com.hluck.materialstudy.app.extension

import android.content.Context
import android.view.View
import android.widget.Toast
import com.google.android.material.snackbar.Snackbar

fun View.showSnackMsg(msg:String,actionText:String? = null,
                      duration:Int = Snackbar.LENGTH_SHORT,
                      block:(() -> Unit)? = null){
    val snackbar = Snackbar.make(this,msg,duration)
    actionText?.let {
        snackbar.setAction(it){
            block?.invoke()
        }
    }
    snackbar.show()
}

fun String.showToast(context: Context,duration:Int = Toast.LENGTH_SHORT){
    Toast.makeText(context,this,duration).show()
}